package com.mofeng.myshop.properties;

import jakarta.annotation.PostConstruct;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;


@Getter
@Configuration
public class FileProperty {
    /**
     **************************** 文件相关 ***********************************
     */
    @Value("${my-setting.file.base-path}")
    private String basePath;

    @Value("${my-setting.file.image-max-size}")
    private Long imageMaxSize;

    @Value("${my-setting.file.music-max-size}")
    private Long musicMaxSize;

    @Value("${my-setting.file.image-path}")
    private String imageSrc;

    @Value("${my-setting.file.music-path}")
    private String musicSrc;

    @Value("${my-setting.file.upload-type}")
    private String uploadType;

    public String getMusicPath(){
        return basePath + musicSrc;
    }
    public String getImagePath(){
        return basePath + imageSrc;
    }
    public String getFileUploadType(){
        return uploadType;
    }
    @PostConstruct
    private void init(){
        if(this.basePath == null){
            this.basePath = System.getProperty("user.dir");
        }
    }

}
